<template>
	<div>
		<van-nav-bar title="今日上新车辆" left-text="返回" left-arrow @click-left="$router.back()" />
		<usedcar-list :data="usedcarList" @onBtnClick="onCarDetail"></usedcar-list>
		<!-- 通用错误 -->
		<van-empty description="今日无上新车辆" v-show="noResult" />
	</div>
</template>

<script>
	export default {
		data() {
			return {
				//车辆列表
				usedcarList: []
			}
		},
		mounted() {
			this.loadTodayCar()
		},
		computed: {
			noResult() {
				if (this.usedcarList.length > 0) {
					return false
				}
				return true
			}
		},
		methods: {
			//加载今日上新车辆
			loadTodayCar() {
				let _this = this
				_this.$axios({
					method: 'get',
					url: '/usedcar/findTodayUsedcar'
				}).then((resp) => {
					_this.usedcarList = resp.data
				})
			},
			//车辆详情页
			onCarDetail(carId) {
				this.$router.push({
					path: "/page/detail",
					query: {
						id: carId
					}
				})
			}
		}
	}
</script>

<style scoped>
</style>
